package com.I9lou.se.lurker.facet.index;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.CountDownLatch;

import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.store.Directory;

public interface TaxonomyWriterFactory {
	
	/**
	 * 获取TaxonomyDirectory对象
	 * 
	 * @return Directory
	 */
	public Directory getTaxonomyDirectory(int appId);
	
	/**
	 * 获取TaxonomyWriter对象
	 * 
	 * @return TaxonomyWriter
	 */
	public Map<Integer,TaxonomyWriter> getTaxonomyWriter();
	
	/**
	 * 获取对应索引路径的reader，因为这个reader需要索引文件提交之后，重新创建
	 * @return
	 */
	public TaxonomyReader getTaxonomyReader(int appId);
	
	/**
	 * 提交聚类索引之后，需要重建TaxonomyReader
	 * @throws CorruptIndexException
	 * @throws IOException
	 */
	public void recreateTaxonomyReader();
	
	/**
	 * You know it
	 */
	public void init();
	
	/**
	 * 用于监控TaxonomyWriterFactory是否可以执行关闭操作的锁:
	 *   当所有外部执行提交操作的调度器都停止后,开始执行factory的释放
	 * @return
	 */
	public CountDownLatch getTaxonomyWriterLatch();
	
	/**
	 * You know it
	 */
	public void destroy();
}
